//
//  AXHdzqPdTgMidCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/11/6.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "AXHdzqPdTgMidCell.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "UITableView+SDAutoTableViewCellHeight.h"

@interface AXHdzqPdTgMidCell ()
/** 线 */
@property (nonatomic , strong) UIView *lineView;

@end

@implementation AXHdzqPdTgMidCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self creatView];
        [self setlayout];
    }
    return self;
}

- (void)creatView {
    
    /** 用户图片 */
    self.userImageView = [[UIImageView alloc]init];
    self.userImageView.image = [UIImage imageNamed:@"j10.jpg"];
    self.userImageView.contentMode =UIViewContentModeScaleAspectFill;
    self.userImageView.clipsToBounds=YES;//
    [self.contentView addSubview:self.userImageView];
    
    /** 团长 */
    self.tzLabel = [[UILabel alloc]init];
    self.tzLabel.textColor = [UIColor colorWithHex:0x666666];
    self.tzLabel.font = FONT_TWELVE;
    self.tzLabel.text = @"团长";
    [self.contentView addSubview:self.tzLabel];
    /** 用户名 */
    self.userNameLabel = [[UILabel alloc]init];
    self.userNameLabel.textColor = [UIColor colorWithHex:0x666666];
    self.userNameLabel.font = FONT_TWELVE;
    self.userNameLabel.text = @"雪花女神经 ";
    [self.contentView addSubview:self.userNameLabel];
    /**  在拼团*/
    self.inPtLabel = [[UILabel alloc]init];
    self.inPtLabel.textAlignment = NSTextAlignmentCenter;
    self.inPtLabel.textColor = [UIColor colorWithHex:0x666666];
    self.inPtLabel.font = FONT_TWELVE;
    self.inPtLabel.text = @"拼团中 还差3人 ";
    [self.contentView addSubview:self.inPtLabel ];
    
  /** 立即拉人 */
    self.lrBtn = [[UIButton alloc]init];
    self.lrBtn.backgroundColor = COLOR_GREEN;
    [self.lrBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.lrBtn setTitle:@"立即拉人" forState:UIControlStateNormal];
    [self.contentView addSubview:self.lrBtn];
    
  /** 立即参团 */
    self.ctBtn = [[UIButton alloc]init];
    self.ctBtn .backgroundColor = COLOR_ORG;
    [self.ctBtn  setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.ctBtn  setTitle:@"立即参团" forState:UIControlStateNormal];
    [self.contentView addSubview:self.ctBtn ];
    
    
    
    
    
}

- (void)setlayout {
    
    self.userImageView.sd_layout
    .centerXEqualToView(self.contentView)
    .topSpaceToView(self.contentView, 10)
    .widthIs(50)
    .heightIs(50);
    
    self.tzLabel.sd_layout
    .leftSpaceToView(self.userImageView, 10)
    .topSpaceToView(self.contentView, 10)
    .widthIs(100)
    .heightIs(20);
    
    self.userNameLabel.sd_layout
    .leftSpaceToView(self.userImageView, 10)
    .topSpaceToView(self.tzLabel, 10)
    .widthIs(100)
    .heightIs(20);
    
    self.inPtLabel.sd_layout
    .centerXEqualToView(self.contentView)
    .topSpaceToView(self.userImageView, 10)
    .widthIs(200)
    .heightIs(30);
    
    self.lrBtn.sd_layout
    .leftSpaceToView(self.contentView, 50)
    .topSpaceToView(self.inPtLabel, 10)
    .widthIs((SCREEN_WIDTH-150)/2)
    .heightIs(30);
    
    self.ctBtn.sd_layout
    .rightSpaceToView(self.contentView, 50)
    .topSpaceToView(self.inPtLabel, 10)
    .widthRatioToView(self.lrBtn, 1)
    .heightRatioToView(self.lrBtn, 1);
    
    
    UIView *lineView = [[UIView alloc]init];
    lineView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.contentView addSubview:lineView];
    
    lineView.sd_layout
    .leftSpaceToView(self.contentView, 0)
    .rightSpaceToView(self.contentView, 0)
    .topSpaceToView(self.ctBtn, 10)
    .heightIs(1);
    
  //cell 自适应第一步
    [self setupAutoHeightWithBottomView:lineView bottomMargin:10];
    
}


@end
